package org.hzy.test;

import java.sql.Time;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.transform.Transformers;

public class MyTest1 {
	static Configuration con = new Configuration().configure();
	static SessionFactory fac = con.buildSessionFactory();
	static Session sess = fac.getCurrentSession();
	public static void TEST_A(){
		System.out.println("!!!!!!!!!!!!!");
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		System.out.println(new java.sql.Date(new Date().getTime())+"  "+new Date()+" "+new Timestamp(System.currentTimeMillis()));
	}
	
	public static void TEST_B(){
		sess.beginTransaction();
		SQLQuery query=sess.createSQLQuery("select eid,my_birthday from my_emp");
//		query.addScalar("my_birthday");
		query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
		List list=query.list();
		System.out.println(list.get(0));
		sess.getTransaction().commit();
		sess.close();
		
	}
	
	public static void main(String[] args) {
		MyTest1.TEST_B();
	}
}
